/**
 * Created by eva on 2020/1/2.
 */
var starPic = new Image();
var stars = [];
var num = 60;
var bStartInited = false;
function drawStar(){
    starPic.src = "src/star.png";
    for(var i = 0; i < num; i++){
        if(!bStartInited){
            stars[i] = new Star();
            stars[i].init();
        }else{
            stars[i].draw();
        }

    }
    bStartInited = true;
}
function Star() {
    this.x = 0;
    this.y = 0;
}
Star.prototype = {
    init : function () {
        this.x = Math.random()*600 + 100;
        this.y = Math.random()*300 + 150;
    },
    draw : function () {
        ctx.drawImage(starPic,this.x,this.y);
    }
}